package Test;

import java.nio.Buffer;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.Scanner;

public class 计算活了多少天 {
    public static void main(String[] args) throws ParseException {
        //请使用代码实现计算你活了多少天，用JDK7和JDK8两种方式完成
        //JDK7
        //规则:只要对时间进行计算或者判断，都需要先获取当前时间的毫秒值
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入你的出生日期：");
        System.out.println("格式：yyyy-MM-dd");
        /*SimpleDateFormat bron=new SimpleDateFormat("yyyy-MM-dd");
        String s = sc.nextLine();
        Date bronparse = bron.parse(s);
        long bronTime = bronparse.getTime();                        JDK7


        long nowTime = System.currentTimeMillis();
        long day = (nowTime - bronTime) / 1000 / 60 / 60 / 24;
        System.out.println(day);*/

        LocalDate now=LocalDate.now();
        LocalDate bron=LocalDate.of(2004,10,23);
        long days =ChronoUnit.DAYS.between(bron,now);
        System.out.println(days);
    }
}
